/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package TPVTarryDAOS;

import Herramientas.PasarelaDatos;
import Herramientas.ResultSets;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Mauricio Alan
 */
public class ClavesAdminDAO {

    private PasarelaDatos db;
    private ResultSets res;

    public ClavesAdminDAO() {
        db = new PasarelaDatos();
        res = new ResultSets();
    }

    public int adminExiste(String clave) {
        int flag = 0;
        db.openDatabase();
        String query ="SELECT COUNT(clave_admin.clave) AS bandera FROM clave_admin WHERE clave_admin.clave='"+clave+"';";
        System.out.println(query);
        ResultSet rst = db.executeQuery(query);
        try {
            if(rst.next()){
            flag = rst.getInt("bandera");
            }else{
            flag =0;
            }
        } catch (SQLException ex) {
            Logger.getLogger(ClavesAdminDAO.class.getName()).log(Level.SEVERE, null, ex);
        }
        db.closeDatabase();
        return flag;
    }

}
